const Router = require('koa-router');
const router = new Router();
const { apikeyList } = require('../utils/apikey')

// 获取钉钉群消息
router.post('login', async ctx => {
    try {
        const { code } = ctx.request.body;
        if (apikeyList.some(item => item.code === code)) {
            ctx.body = {
                code: 200,
                message: 'ok',
                data: code
            }
        } else {
            ctx.body = {
                code: 401,
                message: '无效的登陆码'
            }
        }
    } catch (error) {
        ctx.body = {
            code: 500,
            message: 'ok',
            data: error
        }
    }
})

module.exports = router